<?php
$page = isset($_GET['page'])?$_GET['page']:1;
$size = isset($_GET['limit'])?$_GET['limit']:6;

$dbh = new PDO('mysql:host=localhost;dbname=1705php', "root", "root");
$sql = "select * from `book`";
$res = $dbh->query($sql);
$count = $res->rowCount();
$limit = ($page-1)*$size;

$sqls = "select * from `book` limit $limit,$size";
//echo $sqls;
$ress = $dbh->query($sqls);
$data = $ress->fetchAll(2);
if($data)
{
    $res['code']=0;
    $res['msg']="查询成功";
    $res['count']=$count;
    $res['data']=$data;
}else{
    $res['code']=1;
    $res['msg']="查询失败";
    $res['count']="";
    $res['data']="";
}
echo json_encode($res);
?>